<!DOCTYPE html>
<html>
<head>
	<title></title>
	<meta charset="utf-8">
</head>
<body>

</body>
</html>
<script type="text/javascript">
	//老时间
	function formatDate(format) {
  var date = new Date();
  var o = {
    "y+": date.getFullYear(),
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "h+": date.getHours(),
    "m+": date.getMonth(),
    "s+": date.getSeconds(),
    "q+": Math.floor((date.getMonth() + 3)/3),
    "S+": date.getMilliseconds()
  }
  var str = format;
  var reg = null;
  for(var key in o) {
    reg = new RegExp(key);
    console.log(reg);
    str = str.replace(reg, o[key]);
  }
  // console.log(str);
  return str;
}
//正则替换
function formateDatetime(date,fmt='/'){
  if(!date){
    return '';
  }else if(date&&Object.prototype.toString.call(date)!='[object Date]'){
    if(new Date(date).getDate()){
      date=new Date(date);
    }else{
      return date;
    }
  }
  let y=date.getFullYear(),
      M=date.getMonth()+1,
      d=date.getDate(),
      h=date.getHours(),
      m=date.getMinutes(),
      s=date.getSeconds();
  [M,d,h,m,s]=[M,d,h,m,s].map(v=>v<10?('0'+v):v)
  return [y,M,d].join(fmt)+' '+[h,m,s].join(':');
}
//杂交
function formatDateF(date,fmt='y/M/d h:m:s'){
	if(!date){
    return '';
  }else if(date&&Object.prototype.toString.call(date)!='[object Date]'){
    if(new Date(date).getDate()){
      date=new Date(date);
    }else{
      return date;
    }
  }
  let o = {
    "y+": date.getFullYear(),
    "M+": date.getMonth() + 1,
    "d+": date.getDate(),
    "h+": date.getHours(),
    "m+": date.getMonth(),
    "s+": date.getSeconds(),
    "q+": Math.floor((date.getMonth() + 3)/3),
    "S+": date.getMilliseconds()
  };
  [o['M+'],o['d+'],o['h+'],o['m+'],o['s+']]=[o['M+'],o['d+'],o['h+'],o['m+'],o['s+']].map(v=>v<10?('0'+v):v);
  let str = fmt, reg = null;
  for(let key in o) {
    reg = new RegExp(key);
    str = str.replace(reg, o[key]);
  }
  return str;
}
</script>